<?php
$include = ' 
	<script src="'.W_ROOT.'/js/jquery.js" type="text/javascript"></script>
	<script src="'.W_ROOT.'/js/jquery.validate.js" type="text/javascript"></script>
 ';
$var = '<span style="color:#F00">*</span>';

?>
<script type="text/javascript">
	
	function fname()
	{
		var x=document.forms["buyer_registerForm"]["first_name"].value
		if (x==null || x=="")
		 {
		 	document.getElementById("demo").innerHTML = "Please in put first name!";
		 }else{
			 document.getElementById("demo").innerHTML = "";
		 }
	}
	function lname()
	{
		var x=document.forms["buyer_registerForm"]["last_name"].value
		if (x==null || x=="")
		 {
		 	document.getElementById("demo1").innerHTML = "Please in put last name!";
		 }else{
			 document.getElementById("demo1").innerHTML = "";
		 }
	}	
	function upass()
	{
		var x=document.forms["buyer_registerForm"]["user_pass"].value
		if (x==null || x=="")
		{
		 	document.getElementById("demo2").innerHTML = "Password must be filled out";
		}else{
			 document.getElementById("demo2").innerHTML = "";
		}
	}	
	function cpass()
	{
		var x=document.forms["buyer_registerForm"]["confirm_password"].value
		var pass=document.forms["buyer_registerForm"]["user_pass"].value
		
		if (x==null || x=="")
		{
		  document.getElementById("demo3").innerHTML = "confirm password must be filled out";
		}
		else if(x!=pass){
			document.getElementById("demo3").innerHTML = "Confirm password not the same password!";
		}
		else{
			 document.getElementById("demo3").innerHTML = "";
		}		
	}
	function sword()
	{
		var x=document.forms["buyer_registerForm"]["security_word"].value
		if (x==null || x=="")
		  {
		  	 document.getElementById("demo4").innerHTML = "Security word must be filled out";
		  }
		else{
			 document.getElementById("demo4").innerHTML = "";
		}
	}
	function phon()
	{
		var x=document.forms["buyer_registerForm"]["phone"].value
		if (x==null || x=="")
		  {
		  	 document.getElementById("demo5").innerHTML = "Phone must be filled out";
		  }
		else{
			 document.getElementById("demo5").innerHTML = "";
		}
	}
	function cmail()
	{
		var x=document.forms["buyer_registerForm"]["email"].value
		var atpos=x.indexOf("@");
		var dotpos=x.lastIndexOf(".");
				
		if (x==null || x=="")
	  	{
			 document.getElementById("demo6").innerHTML = "Email must be filled out";
	  	}		
		else if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
	  	{
	   		document.getElementById("demo6").innerHTML = "Not a valid e-mail address";
	  	}
		else{
			 document.getElementById("demo6").innerHTML = "";
		}
	}
	function conmail()
	{
		var x=document.forms["buyer_registerForm"]["confirm_email"].value
		var ex=document.forms["buyer_registerForm"]["email"].value
		if (x==null || x=="")
		  {
		  	 document.getElementById("demo7").innerHTML = "Confirm email must be filled out";
		  }
		else if(x!=ex){
			document.getElementById("demo7").innerHTML = "Confirm email not macth";
		}
		else{
			 document.getElementById("demo7").innerHTML = "";
		}
	}
	function addr()
	{
		var x=document.forms["buyer_registerForm"]["address"].value
		if (x==null || x=="")
		  {
		  	 document.getElementById("demo8").innerHTML = "Address must be filled out";
		  }
		else{
			 document.getElementById("demo8").innerHTML = "";
		}
	}
	
	function tit() {
		if ((document.buyer_registerForm.title[0].checked == false) && (document.buyer_registerForm.title[1].checked == false))
		{
			alert ('Please choose your gender!');
			return false;
		}
		else
		{
			return true;
		}
	}
	function secur(){
		var x=document.forms["buyer_registerForm"]["security_code"].value
		if (x==null || x=="")
		  {
		  	 document.getElementById("demo9").innerHTML = "Security code must be filled out";
		  }
		else{
			 document.getElementById("demo9").innerHTML = "";
		}
	}
</script>	
    <div id="main">
	<table cellpadding="5" cellspacing="5" align="center" width="100%">
    	<tr>
        	<td colspan="2">
            	
            </td>
        </tr>
        <tr>
        	<td colspan="2"><span> <?php echo $var; ?><!--indicates a required field.)--><?php echo $lang['NOTESTAR'];?></span></td>
        </tr>
    
    <!-- Starting form buyer Register -->
    <form name="buyer_registerForm" id="buyer_registerForm" action="<?php echo W_ROOT; ?>/process_register.php?action=register_b" method="post">
    	<tr>
        	<td><label for="first_name"><!--First Name--><?php echo $lang['SHIP_FIR_NAME'];?> <?php echo $var; ?></label></td>
            <td> : <input type="text" name="first_name" id="first_name" value="<?php echo (isset($_SESSION['fname']))?$_SESSION['fname']:'';?>" onblur="fname();" /></td>
        </tr>
        <tr><td colspan="2" id="demo" style="color:#F00; font-style:italic;"></td></tr>
        <tr>
        	<td><label for="last_name"><!--Last Name--><?php echo $lang['SHIP_LAS_NAME'] ;?> <?php echo $var; ?></label></td>
            <td> : <input type="text" name="last_name" id="last_name" value="<?php echo (isset($_SESSION['lname']))?$_SESSION['lname']:'';?>" onblur="lname();" /></td>
        </tr>
        <tr><td colspan="2" id="demo1" style="color:#F00; font-style:italic;"></td></tr>
        <tr>
        	<td><label for="title"><!--Title--> <?php echo $lang['SHIP_TITLE'];?><?php echo $var; ?></label></td>
            <td>: <select id="title" name="title">
                	<option selected="selected"><!--Please select one--><?php echo $lang['PLSSELECTONE'];?></option>
                    <option><!--Mr.--><?php echo $lang['MRR'];?></option>
                    <option><!--Mrs.--><?php echo $lang['MRS'];?></option>
                    <option><!--Miss.--><?php echo $lang['MISSSa'];?></option>
                </select>
            </td>
        </tr>
        <tr>
        	<td><label for="user_pass" style="width:100px;"><!--Password--><?php echo $lang['LOG_PASSWORD'];?><?php echo $var; ?></label></td>
            <td>: <input maxlength="6" type="password" name="user_pass" id="user_pass" value="<?php echo (isset($_SESSION['pass']))?$_SESSION['pass']:'';?>" onblur="upass();" /></td>
        </tr>
         <tr><td colspan="2" id="demo2" style="color:#F00; font-style:italic;"></td></tr>
        <tr>
        	<td><label for="confirm_password"><!--Verify Password--> <?php echo $lang['VERRIFYPASSWORD'];?><?php echo $var; ?></label></td>
            <td>: <input type="password" name="confirm_password" id="confirm_password" onblur="cpass();" /></td>
        </tr>
         <tr><td colspan="2" id="demo3" style="color:#F00; font-style:italic;"></td></tr>
        <tr>
        	<td><label for="security_word"><!--Security word--><?php echo $lang['SECURITYWORD'];?> <?php echo $var;?></label></td>
        	<td>: <input type="text" name="security_word" id="security_word" value="<?php echo (isset($_SESSION['sec_word']))?$_SESSION['sec_word']:'';?>" onblur="sword();" /></td>            
        </tr>
        <tr><td colspan="2" id="demo4" style="color:#F00; font-style:italic;"></td></tr>
        <tr>
        	<td></td>
            <td style="color:#666;"><em>Please input security word  for help, when you forget password!!</em></td>
        </tr>    
        <tr>
        	<td><label for="phone"><!--Telephone--><?php echo $lang['SHIP_PHONE'];?></label></td>
            <td>: <input type="text" name="mobile" id="mobile" value="<?php echo (isset($_SESSION['cmobile']))?$_SESSION['cmobile']:'';?>" /></td>
        </tr>
     
        <tr>
        	<td><label for="mobile"><!--Mobliephone--><?php echo $lang['SHIP_MPHONE'];?> <?php echo $var; ?></label></td>
            <td>: <input type="text" name="phone" id="phone" value="<?php echo (isset($_SESSION['cphone']))?$_SESSION['cphone']:'';?>" onblur="phon();" /></td>
        </tr>
        <tr><td colspan="2" id="demo5" style="color:#F00; font-style:italic;"></td></tr>
        <tr>
        	<td><label for="email"><!--Email--><?php echo $lang['LOG_EMAIL'];?><?php echo $var; ?></label></td>
            <td>: <input type="text" name="email" id="email" value="<?php echo (isset($_SESSION['uemail']))?$_SESSION['uemail']:'';?>" onblur="cmail();" /></td>
        </tr>
        <tr><td colspan="2" id="demo6" style="color:#F00; font-style:italic;"></td></tr>
        <tr>
        	<td><label for="confirm_email"><!--Verify Email--><?php echo $lang['VERIFYEMAILL'];?> <?php echo $var; ?></label></td>
            <td>: <input type="text" name="confirm_email" id="confirm_email" value="<?php echo (isset($_SESSION['uemail']))?$_SESSION['uemail']:'';?>" onblur="conmail();" /></td>
        </tr>
        <tr><td colspan="2" id="demo7" style="color:#F00; font-style:italic;"></td></tr>
        <tr>
        	<td><label for="address"><!--Address--><?php echo $lang['ADDRSELLER'];?> <?php echo $var; ?></label></td>
            <td>: <input type="text" name="address" id="address" value="<?php echo (isset($_SESSION['caddress']))?$_SESSION['caddress']:'';?>" onblur="addr();" /></td>
        </tr>
        <tr><td colspan="2" id="demo8" style="color:#F00; font-style:italic;"></td></tr>
        <tr>
        	<td><label for="country"><!--Country--> <?php echo $lang['SHIP_COUNTRY'];?> <?php echo $var; ?></label></td>
            <?php
				$str = "SELECT id, country_name from tblcountries order by country_name";
				$query = mysql_query($str);
				$num_rows = mysql_num_rows($query);
				
			?>
            </td>
            <td>: 
            	<select name="country_id" id="country">
                	<option selected="selected"><!--Select Contry--><?php echo $lang['SELECTCOUNTRY'];?></option>
                    <?php while($result = mysql_fetch_array($query)){ ?>
                    <option value="<?php echo $result['id'];?>"><?php echo $result['country_name']; ?></option>
                    <?php } ?>
                </select>            
            </td>
        </tr>
        <tr>
        	<td></td>
		    <td><input type="checkbox" name="newsletter" id="newsletter" value="1" />&nbsp;&nbsp; <!--Receive newsletter--><?php echo $lang['RCIEVENEW'];?></td>
        </tr>
        <tr>
        	<td></td>
            <td><img src="<?php echo W_ROOT;?>/captchar/CaptchaSecurityImages.php?width=100&height=40&characters=5" /></td>
        </tr>
        <tr>
        	<td></td>
            <td><input id="security_code" name="security_code" onblur="secur();" /></td>
        </tr>
        <tr><td colspan="2" id="demo9" style="color:#F00; font-style:italic;"></td></tr>
        <tr>
        	<td></td>
            <td>&nbsp;<input type="submit" value="<?php echo $lang['REGISTERR'];?>" name="btnSubmit" onclick="tit();" /></td>
        </tr> 
    </form>  
    </table>  
</div>